﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace TulingMember.Database.Migrations.Migrations
{
    public partial class updatesaleOrderpurchaseOrder : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_cts_SaleOrderDetail_cts_SaleOrder_SaleOrderId",
                table: "cts_SaleOrderDetail");

            migrationBuilder.DropColumn(
                name: "OrderId",
                table: "cts_SaleOrderDetail");

            migrationBuilder.RenameColumn(
                name: "OrderId",
                table: "cts_PurchaseOrderDetail",
                newName: "PurchaseOrderId");

            migrationBuilder.AlterColumn<long>(
                name: "SaleOrderId",
                table: "cts_SaleOrderDetail",
                type: "bigint",
                nullable: false,
                defaultValue: 0L,
                oldClrType: typeof(long),
                oldType: "bigint",
                oldNullable: true);

            migrationBuilder.UpdateData(
                table: "Role",
                keyColumn: "Id",
                keyValue: 142307070910554L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 27, 21, 52, 22, 114, DateTimeKind.Unspecified).AddTicks(9773), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.UpdateData(
                table: "Security",
                keyColumn: "Id",
                keyValue: 142307070910555L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 27, 21, 52, 22, 115, DateTimeKind.Unspecified).AddTicks(678), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.UpdateData(
                table: "Security",
                keyColumn: "Id",
                keyValue: 142307070910556L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 27, 21, 52, 22, 115, DateTimeKind.Unspecified).AddTicks(686), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.UpdateData(
                table: "Security",
                keyColumn: "Id",
                keyValue: 142307070910557L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 27, 21, 52, 22, 115, DateTimeKind.Unspecified).AddTicks(687), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.UpdateData(
                table: "User",
                keyColumn: "Id",
                keyValue: 142307070910551L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 27, 21, 52, 22, 115, DateTimeKind.Unspecified).AddTicks(6724), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.CreateIndex(
                name: "IX_cts_PurchaseOrderDetail_PurchaseOrderId",
                table: "cts_PurchaseOrderDetail",
                column: "PurchaseOrderId");

            migrationBuilder.AddForeignKey(
                name: "FK_cts_PurchaseOrderDetail_cts_PurchaseOrder_PurchaseOrderId",
                table: "cts_PurchaseOrderDetail",
                column: "PurchaseOrderId",
                principalTable: "cts_PurchaseOrder",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_cts_SaleOrderDetail_cts_SaleOrder_SaleOrderId",
                table: "cts_SaleOrderDetail",
                column: "SaleOrderId",
                principalTable: "cts_SaleOrder",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_cts_PurchaseOrderDetail_cts_PurchaseOrder_PurchaseOrderId",
                table: "cts_PurchaseOrderDetail");

            migrationBuilder.DropForeignKey(
                name: "FK_cts_SaleOrderDetail_cts_SaleOrder_SaleOrderId",
                table: "cts_SaleOrderDetail");

            migrationBuilder.DropIndex(
                name: "IX_cts_PurchaseOrderDetail_PurchaseOrderId",
                table: "cts_PurchaseOrderDetail");

            migrationBuilder.RenameColumn(
                name: "PurchaseOrderId",
                table: "cts_PurchaseOrderDetail",
                newName: "OrderId");

            migrationBuilder.AlterColumn<long>(
                name: "SaleOrderId",
                table: "cts_SaleOrderDetail",
                type: "bigint",
                nullable: true,
                oldClrType: typeof(long),
                oldType: "bigint");

            migrationBuilder.AddColumn<long>(
                name: "OrderId",
                table: "cts_SaleOrderDetail",
                type: "bigint",
                nullable: false,
                defaultValue: 0L);

            migrationBuilder.UpdateData(
                table: "Role",
                keyColumn: "Id",
                keyValue: 142307070910554L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 27, 21, 44, 0, 602, DateTimeKind.Unspecified).AddTicks(6279), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.UpdateData(
                table: "Security",
                keyColumn: "Id",
                keyValue: 142307070910555L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 27, 21, 44, 0, 602, DateTimeKind.Unspecified).AddTicks(7313), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.UpdateData(
                table: "Security",
                keyColumn: "Id",
                keyValue: 142307070910556L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 27, 21, 44, 0, 602, DateTimeKind.Unspecified).AddTicks(7323), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.UpdateData(
                table: "Security",
                keyColumn: "Id",
                keyValue: 142307070910557L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 27, 21, 44, 0, 602, DateTimeKind.Unspecified).AddTicks(7325), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.UpdateData(
                table: "User",
                keyColumn: "Id",
                keyValue: 142307070910551L,
                column: "CreatedTime",
                value: new DateTimeOffset(new DateTime(2023, 6, 27, 21, 44, 0, 603, DateTimeKind.Unspecified).AddTicks(4734), new TimeSpan(0, 8, 0, 0, 0)));

            migrationBuilder.AddForeignKey(
                name: "FK_cts_SaleOrderDetail_cts_SaleOrder_SaleOrderId",
                table: "cts_SaleOrderDetail",
                column: "SaleOrderId",
                principalTable: "cts_SaleOrder",
                principalColumn: "Id");
        }
    }
}
